laravel custom attributes

95

laravel custom attributes -

<?php
...

class Movie extends Model
{

    protected $appends = ['cover'];

    //define accessor
    public function getCoverAttribute()
    {
        return json_decode($this->InJson)->cover;
    }
}

Comments

Submit
0 Comments